package edu.gdkm.iodemo;

import java.io.File;
import java.io.IOException;

public class Filedemo {
    public static void main(String[] args) throws IOException {
        File file = new File("D:/test.txt");
        File file2 = new File("D:/javaapp/javademo/data/scores.csv");
        File file3 = new File("./data/scores.csv");
        System.out.println(file.exists());
        System.out.println(file2.exists());
        System.out.println(file3.exists());
        System.out.println(file.isFile());
        System.out.println(file2.isFile());
        System.out.println(file3.isFile());
        System.out.println(file.isDirectory());
        System.out.println(file2.isDirectory());
        System.out.println(file3.isDirectory());
        System.out.println(file.getAbsolutePath());
        System.out.println(file2.getAbsolutePath());
        System.out.println(file3.getAbsolutePath());
        if (file.exists()){
            System.out.println("文件存在");
        }else {
            file.createNewFile();//创建文件
//            file.mkdir();//创建目录
        }
    }
}
